package mgslangpack;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class Menu
{
    public Menu() throws Exception
    {
        try
        {
            Button b1,b2,b3,b4;
            final JFrame jf;
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            final Connection con = DriverManager.getConnection("jdbc:odbc:TheOZ_DB","","");
            final Statement st = con.createStatement();
            jf=new JFrame("Main Menu");
            jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            jf.setSize(900,600);
            jf.setLayout(null);
            jf.setVisible(false);
            Container ctn=jf.getContentPane();
            ctn.setBackground(Color.LIGHT_GRAY);
            Font f1 = new Font("Lucida Handwriting",Font.BOLD,20);
            Font f2 = new Font("Lucida Handwriting",Font.BOLD,30);
            Label l1 = new Label("Welcome");
            l1.setBounds(300,10,700,30);
            l1.setFont(f2);
            jf.add(l1);
            Label l2 = new Label("Login as:");
            l2.setBounds(420,520,100,30);
            l2.setFont(f1);
            jf.add(l2);
            JLabel LogIm,MeIm;
            LogIm=new JLabel(new ImageIcon("the white dress shop.jpg"));
            LogIm.setBounds(10,40,868,461);
            ctn.add(LogIm);
            MeIm=new JLabel(new ImageIcon("wedding-flowers.jpg"));
            MeIm.setBounds(50,400,130,130);
            ctn.add(MeIm);            
            Label l3 = new Label("Copyright 2011");
            l3.setBounds(40,500,150,20);
            l3.setFont(f1);
            jf.add(l3);
            Label l4 = new Label("Eddie DUNIA");
            l4.setBounds(1,520,250,20);
            l4.setFont(f1);
            jf.add(l4);                   
            b1 = new Button("Member");
            b1.setBounds(620,520,80,30);
            b1.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    try
                    {
                        jf.hide();
                        Members m = new Members();
                    }
                    catch(Exception e1){}
                }
            }
            );
            jf.add(b1);
            b2 = new Button("Admin");
            b2.setBounds(530,520,80,30);
            b2.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e2)
                {
                   try
                    {
                       int x=0;
                       String inPass=JOptionPane.showInputDialog(null,"ADMINISTRATOR","password");
                       ResultSet DTPass=st.executeQuery("SELECT AdminPassword FROM Administrator");
                       while(DTPass.next())
                       {
                           String inStore=DTPass.getString(1);

                           if(inStore.equals(inPass))
                           {
                               try
                               {
                                   jf.hide();
                                   new MenuAdmin();
                                   x=x-1;
                               }
                               catch(Exception e1){}
                           }
                           x++;
                       }
                       if(x>=2)
                       {
                           JOptionPane.showMessageDialog(null,"Sorry!!!\n\nWrong Password!","Error",+
                                JOptionPane.INFORMATION_MESSAGE);
                       }
                   }
                   catch(Exception e1){System.out.println("ERROR 1"+e1);}
                }
            }
            );
            jf.add(b2);
            b3 = new Button("Staff");
            b3.setBounds(710,520,80,30);
            b3.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e2)
                {
                   try
                    {
                       int y=0;
                       String inSPass=JOptionPane.showInputDialog(null,"STAFF","Staff ID");
                       ResultSet DTSPass=st.executeQuery("SELECT StaffID FROM Staff");
                       while(DTSPass.next())
                       {
                           String inSStore=DTSPass.getString(1);
                           if(inSStore.equals(inSPass))
                           {
                               try
                               {
                                   jf.hide();
                                   new MenuStaff();
                                   y=y-1;
                               }
                               catch(Exception e3){}
                           }
                           y++;
                       }
                       if(y>=5)
                       {
                           JOptionPane.showMessageDialog(null,"Sorry!!!!\n\nWrong password!","Error",+
                                   JOptionPane.INFORMATION_MESSAGE);
                       }
                   }
                   catch(Exception e1){System.out.println("ERROR 1"+e1);}
                }
            }
            );
            jf.add(b3);
            b4 = new Button("Exit");
            b4.setBounds(800,520,80,30);
            b4.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e6)
                {
                    try
                    {
                        System.exit(0);
                    }
                    catch(Exception e7){}
                }
            }
            );
            jf.add(b4);
            jf.show();
        }
        catch(Exception e1){System.out.println("ERROR 1 for the "+e1);}
    }    
}
/******************************************************************************/